﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="mtabilanssv2_bilanss", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(Mtabilanssv2Bilanss))]
    public class Mtabilanssv2BilanssSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMtabilanssv2Bilanss clazz;
        
        public Mtabilanssv2BilanssSerializer(IMtabilanssv2Bilanss clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.BilansiId!=null) {
                Writer.WriteStartElement("bilansi_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.BilansiId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Ark!=null) {
                Writer.WriteStartElement("ark");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Ark))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MajAlgus!=null) {
                Writer.WriteStartElement("maj_algus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.MajAlgus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MajLopp!=null) {
                Writer.WriteStartElement("maj_lopp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.MajLopp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.HaldId!=null) {
                Writer.WriteStartElement("hald_id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.HaldId))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Aadress!=null) {
                Writer.WriteStartElement("aadress");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Aadress))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Pohiteg!=null) {
                Writer.WriteStartElement("pohiteg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Pohiteg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PtegKood!=null) {
                Writer.WriteStartElement("pteg_kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.PtegKood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Olek!=null) {
                Writer.WriteStartElement("olek");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Olek))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Esitatud!=null) {
                Writer.WriteStartElement("esitatud");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Esitatud))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Sisestatud!=null) {
                Writer.WriteStartElement("sisestatud");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Sisestatud))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ViimPar!=null) {
                Writer.WriteStartElement("viim_par");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.ViimPar))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Muutus!=null) {
                Writer.WriteStartElement("muutus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Muutus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Mkuup!=null) {
                Writer.WriteStartElement("mkuup");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Mkuup))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EmtakVersioon!=null) {
                Writer.WriteStartElement("emtak_versioon");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.EmtakVersioon))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="bilansi_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>bilansi_id");
                }
                clazz.BilansiId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("bilansi_id")).Value;
            }
            if (Reader.LocalName=="ark") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>ark");
                }
                clazz.Ark = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ark")).Value;
            }
            if (Reader.LocalName=="maj_algus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>maj_algus");
                }
                clazz.MajAlgus = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("maj_algus")).Value;
            }
            if (Reader.LocalName=="maj_lopp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>maj_lopp");
                }
                clazz.MajLopp = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("maj_lopp")).Value;
            }
            if (Reader.LocalName=="hald_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>hald_id");
                }
                clazz.HaldId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("hald_id")).Value;
            }
            if (Reader.LocalName=="aadress") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>aadress");
                }
                clazz.Aadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress")).Value;
            }
            if (Reader.LocalName=="pohiteg") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>pohiteg");
                }
                clazz.Pohiteg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pohiteg")).Value;
            }
            if (Reader.LocalName=="pteg_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>pteg_kood");
                }
                clazz.PtegKood = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("pteg_kood")).Value;
            }
            if (Reader.LocalName=="olek") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>olek");
                }
                clazz.Olek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("olek")).Value;
            }
            if (Reader.LocalName=="esitatud") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>esitatud");
                }
                clazz.Esitatud = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("esitatud")).Value;
            }
            if (Reader.LocalName=="sisestatud") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>sisestatud");
                }
                clazz.Sisestatud = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("sisestatud")).Value;
            }
            if (Reader.LocalName=="viim_par") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>viim_par");
                }
                clazz.ViimPar = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("viim_par")).Value;
            }
            if (Reader.LocalName=="muutus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>muutus");
                }
                clazz.Muutus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("muutus")).Value;
            }
            if (Reader.LocalName=="mkuup") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>mkuup");
                }
                clazz.Mkuup = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("mkuup")).Value;
            }
            if (Reader.LocalName=="emtak_versioon") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtabilanssv2_bilanss>emtak_versioon");
                }
                clazz.EmtakVersioon = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("emtak_versioon")).Value;
            }
        }
    }
}
